Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@vladmandic/pilogger
Advanced tools
Simple Logger for NodeJS
Because out of all of the existing modules, I couldn't find one that does what I needed and doesn't carry large number of unnecessary dependencies. There are far more complex loggers available, but sometimes all you need is simplicity with specific feature-set.
This module is written in pure ES6 with minimal dependencies.
Configuration is optional.
If not configured, logging will be to console only and with default format
Configuring inspect options controls how object output is handled
const log = require('pilogger');
const options = {
options.dateFormat: 'YYYY-MM-DD HH:mm:ss',
ringLength: 100,
logFile: './application.log',
accessFile: './accesss.log',
clientFile: './client.log',
inspect: {
showHidden: true,
depth: 5,
colors: true,
showProxy: true,
maxArrayLength: 1024,
maxStringLength: 10240,
breakLength: 200,
compact: 64,
sorted: false,
getters: true,
}
}
log.configure(options);
Messages that are printed to console only, useful for debugging
log.print(...msg);
Messages that are mirrored to console and logFile
(if set), each one prefixed and color coded
log.blank(...msg);
log.data(...msg);
log.state(...msg);
log.info(...msg);
log.warn(...msg);
log.error(...msg);
Example output (note that markdown rules strip colored output):
2020-08-08 10:36:55 INFO: piscan version 0.0.1
2020-08-08 10:36:55 INFO: User: root Platform: linux Arch: x64 Node: v14.4.0
2020-08-08 10:36:55 STATE: Running as root with full capabilities
2020-08-08 10:37:08 DATA: host: pi ip: 192.168.0.100 time: 12,210
2020-08-08 10:37:10 DATA: mac: DC:A6:32:1B:74:D5 vendor: Raspberry Pi os: Linux 5.4
2020-08-08 10:37:12 DATA: ports: 22,139,445,514,873
Messages that are mirrored to console and logFile
(if set), each one prefixed and color coded and with time measurement
const t0 = process.hrtime.bigint();
// do your stuff here
log.timed(t0, ...msg);
Example output:
2020-08-08 10:39:59 TIMED: 1,004 ms Test function execution
Messages that are output to accessFile
(if set) only
Useful for detailed application access log that you don't want printed to console
log.access(...msg);
Messages that are output to clientFile
(if set) only
Useful for logging of any other messages that you don't want printed to console
log.client(...msg);
Access to history ring buffer.
obj.time
is message timestamp, obj.tag
is message type (info, state, data, warn, error), obj.msg
is parsed & concatened message string
for (const line in log.ring) {
console.log(log.ring[line].time, log.ring[line].tag), log.ring[line].msg);
}
FAQs
Simple Logger for NodeJS
The npm package @vladmandic/pilogger receives a total of 0 weekly downloads. As such, @vladmandic/pilogger popularity was classified as not popular.
We found that @vladmandic/pilogger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.